package com.example.flshtarvel.mapper;

import com.example.flshtarvel.entity.Collect;
import com.example.flshtarvel.entity.RouteCollectMap;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CollectMapper {
    //收藏
    @Insert("insert into collect (message_id,message_name,user_id,article_type_id) values(#{messageId},#{messageName},#{userId},#{articleTypeId})")
    public int collect(Collect collect);

    //取消收藏messageId
    @Delete("delete from collect where message_id=#{messageId} and user_id=#{userId}")
    public int deleteCollect(String messageId,String userId);

    //查询收藏    根据文章id 用户id
    @Select("select * from collect where message_id=#{messageId} and user_id=#{userId}")
    public List<Collect> selectCollectByMessageIdAndUserId(String messageId, String userId);

    //查询收藏数   根据文章id
    @Select("select count(*) from collect where message_id=#{messageId}")
    public int selectCollectByMessageId(String messageId);

    //查询收藏 根据用户id
    @Select("select * from collect where collect.user_id = #{userId} ")
    public List<Collect> selectCollectByUserId(String userId);
}
